<template>
	<view class="container">
		<uni-list>
			<uni-list-item showExtraIcon="true" :extraIcon="{type: 'person-filled'}" title="姓名"
				:rightText="user.nickName" />
			<!--      <uni-list-item showExtraIcon="true" :extraIcon="{type: 'phone-filled'}" title="手机号码"
                     :rightText="user.phonenumber"/>
      <uni-list-item showExtraIcon="true" :extraIcon="{type: 'email-filled'}" title="邮箱"
                     :rightText="user.email"/> -->
			<uni-list-item showExtraIcon="true" :extraIcon="{type: 'auth-filled'}" title="岗位" :rightText="postGroup" />
			<uni-list-item showExtraIcon="true" :extraIcon="{type: 'staff-filled'}" title="角色" :rightText="roleGroup" />
			<uni-list-item showExtraIcon="true" :extraIcon="{type: 'person-filled'}" title="所在班级" v-if="isStudent"
				:rightText="classInfo.className" />
			<uni-list-item showExtraIcon="true" :extraIcon="{type: 'calendar-filled'}" title="创建日期"
				:rightText="user.createTime" />
		</uni-list>
	</view>
</template>

<script>
	import {
		getUserProfile
	} from "@/api/system/user"
	// import { log } from "console"

	export default {
		data() {
			return {
				user: {},
				roleGroup: "",
				postGroup: "",
				isStudent: false,
				classInfo: {
					className: ''
				}
			}
		},
		onLoad() {
			this.getUser()
		},
		methods: {
			getUser() {
				getUserProfile().then(response => {
					this.user = response.data
					this.roleGroup = response.roleGroup
					this.postGroup = response.postGroup
					this.class = response.class
					if (response.isStudent) {
						this.isStudent = response.isStudent
					}
					if (response.isStudent) {
						for (var i = 0; i < response.class.length; i++) {
							this.classInfo.className += response.class[i].className + ' - ';
						}
						this.classInfo.className = this.classInfo.className.substring(0, this.classInfo.className
							.length - 2)
					}
				})
			}
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #ffffff;
	}
</style>